//
//  giftStroageItemView.m
//  tcpoctest
//
//  Created by gump on 6/6/13.
//  Copyright (c) 2013 gump. All rights reserved.
//

#import "giftStroageItemView.h"

#import "giftShowView.h"

#import "GiftInfoDataSource.h"

#import "giftStroageDataInfo.h"
#import "GiftInfoDataInfo.h"

@implementation giftStroageItemView

-(void)ReSetImageByID:(NSString *)strid
{
    NSString *imagepath = [[DataControl shareControl].giftInfoDS searchGiftImagePath:strid];
    if (![imagepath isEqualToString:@""]) {
        self.giftImageView.image = [UIImage imageWithContentsOfFile:imagepath];
    }
    else
    {
        self.giftImageView.image = [UIImage imageNamed:@"gift_default.png"];
    }
}

-(void)initUI
{
    self.giftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 60, 60)];
    self.giftImageView.userInteractionEnabled = YES;
    
    UITapGestureRecognizer *singleTouch = [[UITapGestureRecognizer alloc] initWithTarget:self
                                                                                  action:@selector(imageTap:)];
    [self.giftImageView addGestureRecognizer:singleTouch];
    
    self.giftLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 80, 60, 20)];
    self.giftLabel.textAlignment = UITextAlignmentCenter;
    
    [self addSubview:self.giftImageView];
    [self addSubview:self.giftLabel];
}

-(void)imageTap:(id)sender
{
    if (self.gsinfo != nil) {
        GiftInfoDataInfo *giinfo = [[DataControl shareControl].giftInfoDS
                                    getGiftInfoByID:self.gsinfo.strgiftid];
        
        if (giinfo != nil) {
            [ViewManager sharedViewManager].giftshowvc.ginfo = giinfo;
            [ViewManager sharedViewManager].giftshowvc.isendcount = [self.gsinfo.strGiftCount intValue];
            
            [[ViewManager sharedViewManager] showView:VI_GIFT_SHOW
                                     withIsRemoveCurV:false
                                        withDirection:VD_NULL];
        }
    }
    
}

@end
